### 分页模板函数，三个参数含义分别为：当前页、总页数，分页前方的链接
#define paginate(currentPage, totalPage, pageLink)

#setLocal(startPage = currentPage - 2)
#setLocal(endPage = currentPage + 2)

<ul class="pagination pull-right">
#if(totalPage > 10)
	#if(startPage <= 3)
		#setLocal(startPage = 2)
		#setLocal(endPage = 7)
	#end
	#if(endPage + 4 > totalPage)		
		#setLocal(endPage = totalPage - 1)
		#setLocal(startPage = endPage - 5)
	#end

	#if(currentPage - 1 > 4 && totalPage - currentPage > 5)
		<li class="page-item previous">
			<a href="#(link)#(currentPage - 1)"><i class="fa fa-chevron-left"></i></a></li>
		<li><a href="#(link)1">1</a></li>
		<li class="page-item disabled">
			<a href="javascript: void(0);">…</a>
		</li>
		#for(i : [startPage..endPage])
			#if(currentPage == i)
			<li class="page-item active"><a href="javascript: void(0);">#(i)</a></li>
			#else
			<li><a href="#(link)#(i)">#(i)</a></li>
			#end
		#end
		<li class="page-item disabled">
			<a href="javascript: void(0);">…</a>
		</li>
		<li><a href="#(link)#(totalPage)">#(totalPage)</a></li>
		<li class="page-item next">
			<a href="#(link)#(currentPage + 1)"><i class="fa fa-chevron-right"></i></a>
		</li>
	#elseif(currentPage - 1 < 5 && totalPage - currentPage > 4)
		#if(currentPage == 1)
		<li class="page-item previous disabled">
			<a href="javascript: void(0);"><i class="fa fa-chevron-left"></i></a>
		</li>
		<li class="page-item active"><a href="javascript: void(0);">1</a></li>
		#else
		<li class="page-item previous">
		<a href="#(link)#(currentPage - 1)"><i class="fa fa-chevron-left"></i></a>
		</li>
		<li><a href="#(link)1">1</a></li>
		#end
			
		#for(i : [startPage..endPage])
			#if(currentPage == i)
			<li class="page-item active"><a href="javascript: void(0);">#(i)</a></li>
			#else
			<li><a href="#(link)#(i)">#(i)</a></li>
			#end
		#end
		
		<li class="page-item disabled">
			<a href="javascript: void(0);">…</a>
		</li>
		<li><a href="#(link)#(totalPage)">#(totalPage)</a></li>
		<li class="page-item next">
			<a href="#(link)#(currentPage + 1)"><i class="fa fa-chevron-right"></i></a>
		</li>
	#elseif(currentPage - 1 > 4 && totalPage - currentPage < 6)
		<li class="page-item previous">
			<a href="#(link)#(currentPage - 1)"><i class="fa fa-chevron-left"></i></a></li>
		<li><a href="#(link)1">1</a></li>
		<li class="page-item disabled">
			<a href="javascript: void(0);">…</a>
		</li>
		#for(i : [startPage..endPage])
			#if(currentPage == i)
			<li class="page-item active"><a href="javascript: void(0);">#(i)</a></li>		
			#else
			<li><a href="#(link)#(i)">#(i)</a></li>
			#end
		#end		
		#if(currentPage == totalPage)
		<li class="page-item active"><a href="javascript: void(0);">#(totalPage)</a></li>
		<li class="page-item next disabled">
			<a href="javascript: void(0);"><i class="fa fa-chevron-right"></i></a>
		</li>
		#else
		<li><a href="#(link)#(totalPage)">#(totalPage)</a></li>
		<li class="page-item next">
			<a href="#(link)#(currentPage + 1)"><i class="fa fa-chevron-right"></i></a>
		</li>
		#end			
	#else
	#(currentPage)
	#end
#elseif(totalPage > 1)
	#for(i : [1..totalPage])
		#if(currentPage == i)
		<li class="page-item active"><a href="javascript: void(0);">#(i)</a></li>
		#else
		<li><a href="#(link)#(i)">#(i)</a></li>
		#end
	#end
#else

#end
</ul>

#end